package com.mdl.springmvc.ioStream.io;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

/**
 * @Desc
 * @Author madengling
 * @Time 2020/12/28 14:52
 */
public class FileReaderTest04 {
    private static final String PATH = "G:\\dhcc\\idea\\MavenProject\\src\\main\\webapp\\files\\";
    public static void main(String[] args) {
        File file = new File(PATH+"a.txt");
        FileReader fr = null;
        try {
            //使用File对象创建流对象，也可以使用文件名称创建流对象
            fr = new FileReader(file);
            int b;
            while ((b=fr.read()) != -1){
                System.out.print((char) b);
            }
            System.out.println();
            System.out.println("=================");
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                fr.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
